package com.doitedu.hbase.client;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*;

/**
 * @Date 2021/12/13
 * @Created by HANGGE
 * @Description
 *   table.delete(delete)  如果delete对象中没有进行其他的设置 直接删除行数据
 *   delete.addColumn("cf".getBytes() ,"job".getBytes()) ;  删除指定的属性列
 *   delete.addFamily("cf2".getBytes()) ; 删除指定的列族数据
 */
public class C03_Delete {
    public static void main(String[] args) throws Exception {
        // 1 获取连接
        Configuration conf = HBaseConfiguration.create();
        conf.set("hbase.zookeeper.quorum" , "linux01:2181,linux02:2181,linux03:2181");
        Connection conn = ConnectionFactory.createConnection(conf);

         // 2 获取操作的核心对象
     //   Table table = conn.getTable(TableName.valueOf("tb_teacher"));
        Table table = conn.getTable(TableName.valueOf("tb_a"));
        // public Delete(byte[] row)
        Delete delete = new Delete("rk001".getBytes());
      //  delete.addColumn("cf".getBytes() ,"job".getBytes()) ;
        delete.addFamily("cf2".getBytes()) ;
        table.delete(delete);
        table.close();
        conn.close();
    }
}
